$(function (){
    //用户Id
    const id=$(".content").attr("information-id")
    //获取账户Id
    let accountId =$(".content").attr("accountId");
    //获取账户名称
    let accountName =$(".content").attr("accountName");
    //加密
    let aesKeyUtil = new Aes_key_util();
    let encryptedInformationId = aesKeyUtil.encrypt(id);


    //根据状态使展示内容不同
    const status=$(".order-status").text()
    if(status!=""){
        $(".empty").css("display","none")
        $(".order-div").css("display","block")
    }else{
        $(".empty").css("display","block")
        $(".order-div").css("display","none")
    }
    //根据状态使展示标题颜色不同
    const orderState=$(".content").attr("state");
    if(orderState==""){
        $(".first-active-order a").css("color","#757575")
        $(".valid-orders").css("color","#FF6700")
    }else if(orderState=="0"){
        $(".first-active-order a").css("color","#757575")
        $(".treat-paid").css("color","#FF6700")
    }else if(orderState=="999"){
        $(".first-active-order a").css("color","#757575")
        $(".expired-orders").css("color","#FF6700")
    }else{
        $(".first-active-order a").css("color","#757575")
        $(".treat-receiving").css("color","#FF6700")
    }


    if("已退款"==status || "未发货"==status || "分拣中"==status || "送货中"==status || "运货中"==status){
        $(".appraise-singles").css("display","none")
        $(".apply-after-sales").css("display","none")
    }else if("已收货"==status){
        $(".order-substance-set div").css("display","block")
    }
    //订单搜索
    $(".search-img").on("click",function (){
        window.location.href="http://localhost:8083/www.xiaomi.com/center?informationId="
            +encodeURIComponent(encryptedInformationId)+"&searchInput="+$(".search-input input").val()+"&menu=1&name="+accountName+"&accountId="+accountId;
    })

    $(".filter-list-order li a").on("click",function () {
        let state="";
        if("待支付"==$(this).text()){
            state=0;
        }else if("待收货"==$(this).text()){
            state=4678;
        }else if("过期订单"==$(this).text()){
            state=999;
        }else {
            state="";
        }
        window.location.href="http://localhost:8083/www.xiaomi.com/center?informationId="
            +encodeURIComponent(encryptedInformationId)+"&status="+state+"&menu=1&name="+accountName+"&accountId="+accountId;
    })
    $(".order-span-right").on("click",function (){
        window.location.href="http://localhost:8083/www.xiaomi.com/center?informationId="
            +encodeURIComponent(encryptedInformationId)+"&ordersId="+$(this).attr("orders-id")+"&menu=1&name="+accountName+"&accountId="+accountId;
        location.reload();
    })
    $(".order-details").on("click",function (){
        window.location.href="http://localhost:8083/www.xiaomi.com/center?informationId="
            +encodeURIComponent(encryptedInformationId)+"&ordersId="+$(this).attr("orders-id")+"&menu=11&name="+accountName+"&accountId="+accountId;
    })

})